//
//  XMGNewFeatureCell.m
//  彩票
//
//  Created by apple on 20/3/28.
//
//

#import "XMGNewFeatureCell.h"

#import "XMGADViewController.h"

@interface XMGNewFeatureCell()

@property (nonatomic ,weak)UIImageView *imageV;

/** 注释*/
@property (nonatomic ,weak)UIButton *startBtn;

@end

@implementation XMGNewFeatureCell

- (UIImageView *)imageV {
    
    if (_imageV == nil) {
        UIImageView *imageV = [[UIImageView alloc] init];
        imageV.frame = self.bounds;
        [self.contentView addSubview:imageV];
        _imageV = imageV;
    }
    return _imageV;
}


- (UIButton *)startBtn {
    
    if (_startBtn == nil) {
        
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setImage:[UIImage imageNamed:@"guideStart"] forState:UIControlStateNormal];
        //先去自适应大小
        [btn sizeToFit];
        //设置位置
         btn.center = CGPointMake(self.bounds.size.width * 0.5, self.bounds.size.height * 0.7);
        [self.contentView addSubview:btn];
        
        //监听按钮的点击
        [btn addTarget:self action:@selector(startBtnClick) forControlEvents:UIControlEventTouchUpInside];
        
        _startBtn = btn;
    }
    return _startBtn;
}

/**
 *  立即体验按钮的点击qqqqqqqqq
 */
- (void)startBtnClick {
    
    
    //[[NSUserDefaults standardUserDefaults] setObject:curVersion forKey:XMGVersion];
    
    //切换程序的主框架
    //切换窗口的根控制器
    XMGADViewController *adVC = [[XMGADViewController alloc]init];
    
    [UIApplication sharedApplication].keyWindow.rootViewController = adVC;
}



- (void)setImage:(UIImage *)image {
    _image = image;
    self.imageV.image = image;
}

/**
 *  添加立即体验
 *
 *  @param indexPath 当前是第几个格子
 *  @param count     格子的总个数
 */


- (void)setStartBtn:(NSIndexPath *)indexPath count:(int)count {
    if (indexPath.item == count - 1) {
        self.startBtn.hidden = NO;
    }else {
        //隐藏开始按钮
        self.startBtn.hidden = YES;
    }
}



@end
